package com.hardware.utils;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.hardware.entity.Orders;
import org.apache.poi.ss.formula.functions.T;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class ExcelUtils {

    public static void writeExcel(HttpServletResponse response, List<Orders> list) throws IOException {
        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
        //定义工作表对象
        WriteSheet sheet = EasyExcel.writerSheet(0, "sheet").head(Orders.class).build();
        //写入数据
        excelWriter.write(list,sheet);
        excelWriter.finish();

    }
}
